# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) Contributors to the OpenEXR Project.

load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@rules_cc//cc:defs.bzl", "cc_library")

config_setting(
    name = "windows",
    constraint_values = ["@platforms//os:windows"],
)

expand_template(
    name = "IexConfig",
    out = "src/lib/Iex/IexConfig.h",
    substitutions = {
        "@IEX_INTERNAL_NAMESPACE@": "Iex_3_3",
        "@IEX_NAMESPACE_CUSTOM@": "0",
        "@IEX_NAMESPACE@": "Iex",
    },
    template = "cmake/IexConfig.h.in",
)

expand_template(
    name = "IexConfigInternal",
    out = "src/lib/Iex/IexConfigInternal.h",
    substitutions = {
        "#cmakedefine HAVE_UCONTEXT_H 1": "/* #undef HAVE_UCONTEXT_H */",
        "#cmakedefine IEX_HAVE_CONTROL_REGISTER_SUPPORT 1": "/* #undef IEX_HAVE_CONTROL_REGISTER_SUPPORT */",
        "#cmakedefine IEX_HAVE_SIGCONTEXT_CONTROL_REGISTER_SUPPORT 1": "/* #undef IEX_HAVE_SIGCONTEXT_CONTROL_REGISTER_SUPPORT */",
    },
    template = "cmake/IexConfigInternal.h.in",
)

expand_template(
    name = "IlmThreadConfig",
    out = "src/lib/IlmThread/IlmThreadConfig.h",
    substitutions = {
        "@ILMTHREAD_INTERNAL_NAMESPACE@": "IlmThread_3_3",
        "@ILMTHREAD_NAMESPACE_CUSTOM@": "0",
        "@ILMTHREAD_NAMESPACE@": "IlmThread",
        "#cmakedefine01 ILMTHREAD_HAVE_POSIX_SEMAPHORES": "#define ILMTHREAD_HAVE_POSIX_SEMAPHORES 0",
        "#cmakedefine01 ILMTHREAD_THREADING_ENABLED": "#define ILMTHREAD_THREADING_ENABLED 1",
        "#cmakedefine01 ILMTHREAD_USE_TBB": "#define ILMTHREAD_USE_TBB 0",
    },
    template = "cmake/IlmThreadConfig.h.in",
)

expand_template(
    name = "OpenEXRConfig",
    out = "src/lib/OpenEXR/OpenEXRConfig.h",
    substitutions = {
        "@OPENEXR_IMF_NAMESPACE@": "Imf",
        "@OPENEXR_INTERNAL_IMF_NAMESPACE@": "Imf_3_3",
        "@OPENEXR_LIB_VERSION@": "3.3.2",
        "@OPENEXR_NAMESPACE_CUSTOM@": "3.3.2",
        "@OPENEXR_PACKAGE_NAME@": "OpenEXR 3.3.2",
        "@OPENEXR_VERSION_EXTRA@": "",
        "@OPENEXR_VERSION@": "3.3.2",
        "@OPENEXR_VERSION_MAJOR@": "3",
        "@OPENEXR_VERSION_MINOR@": "3",
        "@OPENEXR_VERSION_PATCH@": "2",
        "#cmakedefine OPENEXR_ENABLE_API_VISIBILITY": "#define OPENEXR_ENABLE_API_VISIBILITY",
        "#cmakedefine OPENEXR_HAVE_LARGE_STACK 1": "/* #undef OPENEXR_HAVE_LARGE_STACK */",
    },
    template = "cmake/OpenEXRConfig.h.in",
)

expand_template(
    name = "OpenEXRConfigInternal",
    out = "src/lib/OpenEXR/OpenEXRConfigInternal.h",
    substitutions = {
        "#cmakedefine OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1": "#define OPENEXR_IMF_HAVE_COMPLETE_IOMANIP 1",
        "#cmakedefine OPENEXR_IMF_HAVE_DARWIN 1": "/* #undef OPENEXR_IMF_HAVE_DARWIN */",
        "#cmakedefine OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX 1": "/* #undef OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX */",
        "#cmakedefine OPENEXR_IMF_HAVE_LINUX_PROCFS 1": "/* #undef OPENEXR_IMF_HAVE_LINUX_PROCFS */",
        "#cmakedefine OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN 1": "/* #undef OPENEXR_IMF_HAVE_SYSCONF_NPROCESSORS_ONLN */",
        "#cmakedefine OPENEXR_MISSING_ARM_VLD1 0": "/* #undef OPENEXR_MISSING_ARM_VLD1 */",
    },
    template = "cmake/OpenEXRConfigInternal.h.in",
)

cc_library(
    name = "Iex",
    srcs = [
        "src/lib/Iex/IexBaseExc.cpp",
        "src/lib/Iex/IexMathFloatExc.cpp",
        "src/lib/Iex/IexMathFpu.cpp",
        "src/lib/Iex/IexThrowErrnoExc.cpp",
        "src/lib/OpenEXRCore/openexr_version.h",
    ],
    hdrs = [
        "src/lib/Iex/Iex.h",
        "src/lib/Iex/IexBaseExc.h",
        "src/lib/Iex/IexConfig.h",
        "src/lib/Iex/IexConfigInternal.h",
        "src/lib/Iex/IexErrnoExc.h",
        "src/lib/Iex/IexExport.h",
        "src/lib/Iex/IexForward.h",
        "src/lib/Iex/IexMacros.h",
        "src/lib/Iex/IexMathExc.h",
        "src/lib/Iex/IexMathFloatExc.h",
        "src/lib/Iex/IexMathFpu.h",
        "src/lib/Iex/IexMathIeeeExc.h",
        "src/lib/Iex/IexNamespace.h",
        "src/lib/Iex/IexThrowErrnoExc.h",
        "src/lib/OpenEXR/OpenEXRConfig.h",
    ],
    features = select({
        ":windows": ["windows_export_all_symbols"],
        "//conditions:default": [],
    }),
    includes = [
        "src/lib",
        "src/lib/Iex",
        "src/lib/OpenEXR",
        "src/lib/OpenEXRCore",
    ],
)

cc_library(
    name = "IlmThread",
    srcs = [
        "src/lib/IlmThread/IlmThread.cpp",
        "src/lib/IlmThread/IlmThreadPool.cpp",
        "src/lib/IlmThread/IlmThreadSemaphore.cpp",
        "src/lib/IlmThread/IlmThreadSemaphoreOSX.cpp",
        "src/lib/IlmThread/IlmThreadSemaphorePosix.cpp",
        "src/lib/IlmThread/IlmThreadSemaphorePosixCompat.cpp",
        "src/lib/IlmThread/IlmThreadSemaphoreWin32.cpp",
        "src/lib/OpenEXRCore/openexr_version.h",
    ],
    hdrs = [
        "src/lib/IlmThread/IlmThread.h",
        "src/lib/IlmThread/IlmThreadConfig.h",
        "src/lib/IlmThread/IlmThreadExport.h",
        "src/lib/IlmThread/IlmThreadForward.h",
        "src/lib/IlmThread/IlmThreadMutex.h",
        "src/lib/IlmThread/IlmThreadNamespace.h",
        "src/lib/IlmThread/IlmThreadPool.h",
        "src/lib/IlmThread/IlmThreadProcessGroup.h",
        "src/lib/IlmThread/IlmThreadSemaphore.h",
    ],
    features = select({
        ":windows": ["windows_export_all_symbols"],
        "//conditions:default": [],
    }),
    includes = [
        "src/lib",
        "src/lib/IlmThread",
        "src/lib/OpenEXRCore",
    ],
    deps = [":Iex"],
)

cc_library(
    name = "OpenEXRCore",
    srcs = [
        "src/lib/IlmThread/IlmThreadConfig.h",
        "src/lib/OpenEXR/OpenEXRConfig.h",
        "src/lib/OpenEXR/OpenEXRConfigInternal.h",
        "src/lib/OpenEXRCore/attributes.c",
        "src/lib/OpenEXRCore/backward_compatibility.h",
        "src/lib/OpenEXRCore/base.c",
        "src/lib/OpenEXRCore/channel_list.c",
        "src/lib/OpenEXRCore/chunk.c",
        "src/lib/OpenEXRCore/coding.c",
        "src/lib/OpenEXRCore/compression.c",
        "src/lib/OpenEXRCore/context.c",
        "src/lib/OpenEXRCore/debug.c",
        "src/lib/OpenEXRCore/decoding.c",
        "src/lib/OpenEXRCore/dwaLookups.h",
        "src/lib/OpenEXRCore/encoding.c",
        "src/lib/OpenEXRCore/float_vector.c",
        "src/lib/OpenEXRCore/internal_attr.h",
        "src/lib/OpenEXRCore/internal_b44.c",
        "src/lib/OpenEXRCore/internal_b44_table.c",
        "src/lib/OpenEXRCore/internal_channel_list.h",
        "src/lib/OpenEXRCore/internal_coding.h",
        "src/lib/OpenEXRCore/internal_compress.h",
        "src/lib/OpenEXRCore/internal_constants.h",
        "src/lib/OpenEXRCore/internal_cpuid.h",
        "src/lib/OpenEXRCore/internal_decompress.h",
        "src/lib/OpenEXRCore/internal_dwa.c",
        "src/lib/OpenEXRCore/internal_dwa_channeldata.h",
        "src/lib/OpenEXRCore/internal_dwa_classifier.h",
        "src/lib/OpenEXRCore/internal_dwa_compressor.h",
        "src/lib/OpenEXRCore/internal_dwa_decoder.h",
        "src/lib/OpenEXRCore/internal_dwa_encoder.h",
        "src/lib/OpenEXRCore/internal_dwa_helpers.h",
        "src/lib/OpenEXRCore/internal_dwa_simd.h",
        "src/lib/OpenEXRCore/internal_file.h",
        "src/lib/OpenEXRCore/internal_float_vector.h",
        "src/lib/OpenEXRCore/internal_huf.c",
        "src/lib/OpenEXRCore/internal_huf.h",
        "src/lib/OpenEXRCore/internal_memory.h",
        "src/lib/OpenEXRCore/internal_opaque.h",
        "src/lib/OpenEXRCore/internal_piz.c",
        "src/lib/OpenEXRCore/internal_posix_file_impl.h",
        "src/lib/OpenEXRCore/internal_preview.h",
        "src/lib/OpenEXRCore/internal_pxr24.c",
        "src/lib/OpenEXRCore/internal_rle.c",
        "src/lib/OpenEXRCore/internal_string.h",
        "src/lib/OpenEXRCore/internal_string_vector.h",
        "src/lib/OpenEXRCore/internal_structs.c",
        "src/lib/OpenEXRCore/internal_structs.h",
        "src/lib/OpenEXRCore/internal_util.h",
        "src/lib/OpenEXRCore/internal_win32_file_impl.h",
        "src/lib/OpenEXRCore/internal_xdr.h",
        "src/lib/OpenEXRCore/internal_zip.c",
        "src/lib/OpenEXRCore/memory.c",
        "src/lib/OpenEXRCore/opaque.c",
        "src/lib/OpenEXRCore/openexr_version.h",
        "src/lib/OpenEXRCore/pack.c",
        "src/lib/OpenEXRCore/parse_header.c",
        "src/lib/OpenEXRCore/part.c",
        "src/lib/OpenEXRCore/part_attr.c",
        "src/lib/OpenEXRCore/preview.c",
        "src/lib/OpenEXRCore/std_attr.c",
        "src/lib/OpenEXRCore/string.c",
        "src/lib/OpenEXRCore/string_vector.c",
        "src/lib/OpenEXRCore/unpack.c",
        "src/lib/OpenEXRCore/validation.c",
        "src/lib/OpenEXRCore/write_header.c",
    ],
    hdrs = [
        "src/lib/OpenEXRCore/openexr.h",
        "src/lib/OpenEXRCore/openexr_attr.h",
        "src/lib/OpenEXRCore/openexr_base.h",
        "src/lib/OpenEXRCore/openexr_chunkio.h",
        "src/lib/OpenEXRCore/openexr_coding.h",
        "src/lib/OpenEXRCore/openexr_compression.h",
        "src/lib/OpenEXRCore/openexr_config.h",
        "src/lib/OpenEXRCore/openexr_context.h",
        "src/lib/OpenEXRCore/openexr_debug.h",
        "src/lib/OpenEXRCore/openexr_decode.h",
        "src/lib/OpenEXRCore/openexr_encode.h",
        "src/lib/OpenEXRCore/openexr_errors.h",
        "src/lib/OpenEXRCore/openexr_part.h",
        "src/lib/OpenEXRCore/openexr_std_attr.h",
    ],
    copts = select({
        ":windows": [],
        "//conditions:default": [
            "-Wno-error",
        ],
    }),
    features = select({
        ":windows": ["windows_export_all_symbols"],
        "//conditions:default": [],
    }),
    includes = [
        "src/lib/IlmThread",
        "src/lib/OpenEXR",
        "src/lib/OpenEXRCore",
    ],
    linkopts =
        select({
            ":windows": [],
            "//conditions:default": [
                "-pthread",
            ],
        }),
    visibility = ["//visibility:public"],
    deps = [
        "@imath",
        "@libdeflate//:deflate",
    ],
)

cc_library(
    name = "OpenEXR",
    srcs = [
        "src/lib/OpenEXR/ImfAcesFile.cpp",
        "src/lib/OpenEXR/ImfAttribute.cpp",
        "src/lib/OpenEXR/ImfB44Compressor.cpp",
        "src/lib/OpenEXR/ImfBoxAttribute.cpp",
        "src/lib/OpenEXR/ImfCRgbaFile.cpp",
        "src/lib/OpenEXR/ImfChannelList.cpp",
        "src/lib/OpenEXR/ImfChannelListAttribute.cpp",
        "src/lib/OpenEXR/ImfChromaticities.cpp",
        "src/lib/OpenEXR/ImfChromaticitiesAttribute.cpp",
        "src/lib/OpenEXR/ImfCompositeDeepScanLine.cpp",
        "src/lib/OpenEXR/ImfCompression.cpp",
        "src/lib/OpenEXR/ImfCompressionAttribute.cpp",
        "src/lib/OpenEXR/ImfCompressor.cpp",
        "src/lib/OpenEXR/ImfContext.cpp",
        "src/lib/OpenEXR/ImfContextInit.cpp",
        "src/lib/OpenEXR/ImfConvert.cpp",
        "src/lib/OpenEXR/ImfDeepCompositing.cpp",
        "src/lib/OpenEXR/ImfDeepFrameBuffer.cpp",
        "src/lib/OpenEXR/ImfDeepImageStateAttribute.cpp",
        "src/lib/OpenEXR/ImfDeepScanLineInputFile.cpp",
        "src/lib/OpenEXR/ImfDeepScanLineInputPart.cpp",
        "src/lib/OpenEXR/ImfDeepScanLineOutputFile.cpp",
        "src/lib/OpenEXR/ImfDeepScanLineOutputPart.cpp",
        "src/lib/OpenEXR/ImfDeepTiledInputFile.cpp",
        "src/lib/OpenEXR/ImfDeepTiledInputPart.cpp",
        "src/lib/OpenEXR/ImfDeepTiledOutputFile.cpp",
        "src/lib/OpenEXR/ImfDeepTiledOutputPart.cpp",
        "src/lib/OpenEXR/ImfDoubleAttribute.cpp",
        "src/lib/OpenEXR/ImfDwaCompressor.cpp",
        "src/lib/OpenEXR/ImfEnvmap.cpp",
        "src/lib/OpenEXR/ImfEnvmapAttribute.cpp",
        "src/lib/OpenEXR/ImfFastHuf.cpp",
        "src/lib/OpenEXR/ImfFloatAttribute.cpp",
        "src/lib/OpenEXR/ImfFloatVectorAttribute.cpp",
        "src/lib/OpenEXR/ImfFrameBuffer.cpp",
        "src/lib/OpenEXR/ImfFramesPerSecond.cpp",
        "src/lib/OpenEXR/ImfGenericInputFile.cpp",
        "src/lib/OpenEXR/ImfGenericOutputFile.cpp",
        "src/lib/OpenEXR/ImfHeader.cpp",
        "src/lib/OpenEXR/ImfHuf.cpp",
        "src/lib/OpenEXR/ImfIDManifest.cpp",
        "src/lib/OpenEXR/ImfIDManifestAttribute.cpp",
        "src/lib/OpenEXR/ImfIO.cpp",
        "src/lib/OpenEXR/ImfInputFile.cpp",
        "src/lib/OpenEXR/ImfInputPart.cpp",
        "src/lib/OpenEXR/ImfInputPartData.cpp",
        "src/lib/OpenEXR/ImfIntAttribute.cpp",
        "src/lib/OpenEXR/ImfKeyCode.cpp",
        "src/lib/OpenEXR/ImfKeyCodeAttribute.cpp",
        "src/lib/OpenEXR/ImfLineOrderAttribute.cpp",
        "src/lib/OpenEXR/ImfLut.cpp",
        "src/lib/OpenEXR/ImfMatrixAttribute.cpp",
        "src/lib/OpenEXR/ImfMisc.cpp",
        "src/lib/OpenEXR/ImfMultiPartInputFile.cpp",
        "src/lib/OpenEXR/ImfMultiPartOutputFile.cpp",
        "src/lib/OpenEXR/ImfMultiView.cpp",
        "src/lib/OpenEXR/ImfOpaqueAttribute.cpp",
        "src/lib/OpenEXR/ImfOutputFile.cpp",
        "src/lib/OpenEXR/ImfOutputPart.cpp",
        "src/lib/OpenEXR/ImfOutputPartData.cpp",
        "src/lib/OpenEXR/ImfPartType.cpp",
        "src/lib/OpenEXR/ImfPizCompressor.cpp",
        "src/lib/OpenEXR/ImfPreviewImage.cpp",
        "src/lib/OpenEXR/ImfPreviewImageAttribute.cpp",
        "src/lib/OpenEXR/ImfPxr24Compressor.cpp",
        "src/lib/OpenEXR/ImfRational.cpp",
        "src/lib/OpenEXR/ImfRationalAttribute.cpp",
        "src/lib/OpenEXR/ImfRgbaFile.cpp",
        "src/lib/OpenEXR/ImfRgbaYca.cpp",
        "src/lib/OpenEXR/ImfRle.cpp",
        "src/lib/OpenEXR/ImfRleCompressor.cpp",
        "src/lib/OpenEXR/ImfScanLineInputFile.cpp",
        "src/lib/OpenEXR/ImfStandardAttributes.cpp",
        "src/lib/OpenEXR/ImfStdIO.cpp",
        "src/lib/OpenEXR/ImfStringAttribute.cpp",
        "src/lib/OpenEXR/ImfStringVectorAttribute.cpp",
        "src/lib/OpenEXR/ImfSystemSpecific.cpp",
        "src/lib/OpenEXR/ImfTestFile.cpp",
        "src/lib/OpenEXR/ImfThreading.cpp",
        "src/lib/OpenEXR/ImfTileDescriptionAttribute.cpp",
        "src/lib/OpenEXR/ImfTileOffsets.cpp",
        "src/lib/OpenEXR/ImfTiledInputFile.cpp",
        "src/lib/OpenEXR/ImfTiledInputPart.cpp",
        "src/lib/OpenEXR/ImfTiledMisc.cpp",
        "src/lib/OpenEXR/ImfTiledOutputFile.cpp",
        "src/lib/OpenEXR/ImfTiledOutputPart.cpp",
        "src/lib/OpenEXR/ImfTiledRgbaFile.cpp",
        "src/lib/OpenEXR/ImfTimeCode.cpp",
        "src/lib/OpenEXR/ImfTimeCodeAttribute.cpp",
        "src/lib/OpenEXR/ImfVecAttribute.cpp",
        "src/lib/OpenEXR/ImfVersion.cpp",
        "src/lib/OpenEXR/ImfWav.cpp",
        "src/lib/OpenEXR/ImfZip.cpp",
        "src/lib/OpenEXR/ImfZipCompressor.cpp",
    ],
    hdrs = [
        "src/lib/Iex/IexConfig.h",
        "src/lib/Iex/IexConfigInternal.h",
        "src/lib/IlmThread/IlmThreadConfig.h",
        "src/lib/OpenEXR/ImfAcesFile.h",
        "src/lib/OpenEXR/ImfArray.h",
        "src/lib/OpenEXR/ImfAttribute.h",
        "src/lib/OpenEXR/ImfAutoArray.h",
        "src/lib/OpenEXR/ImfB44Compressor.h",
        "src/lib/OpenEXR/ImfBoxAttribute.h",
        "src/lib/OpenEXR/ImfCRgbaFile.h",
        "src/lib/OpenEXR/ImfChannelList.h",
        "src/lib/OpenEXR/ImfChannelListAttribute.h",
        "src/lib/OpenEXR/ImfCheckedArithmetic.h",
        "src/lib/OpenEXR/ImfChromaticities.h",
        "src/lib/OpenEXR/ImfChromaticitiesAttribute.h",
        "src/lib/OpenEXR/ImfCompositeDeepScanLine.h",
        "src/lib/OpenEXR/ImfCompression.h",
        "src/lib/OpenEXR/ImfCompressionAttribute.h",
        "src/lib/OpenEXR/ImfCompressor.h",
        "src/lib/OpenEXR/ImfContext.h",
        "src/lib/OpenEXR/ImfContextInit.h",
        "src/lib/OpenEXR/ImfConvert.h",
        "src/lib/OpenEXR/ImfDeepCompositing.h",
        "src/lib/OpenEXR/ImfDeepFrameBuffer.h",
        "src/lib/OpenEXR/ImfDeepImageState.h",
        "src/lib/OpenEXR/ImfDeepImageStateAttribute.h",
        "src/lib/OpenEXR/ImfDeepScanLineInputFile.h",
        "src/lib/OpenEXR/ImfDeepScanLineInputPart.h",
        "src/lib/OpenEXR/ImfDeepScanLineOutputFile.h",
        "src/lib/OpenEXR/ImfDeepScanLineOutputPart.h",
        "src/lib/OpenEXR/ImfDeepTiledInputFile.h",
        "src/lib/OpenEXR/ImfDeepTiledInputPart.h",
        "src/lib/OpenEXR/ImfDeepTiledOutputFile.h",
        "src/lib/OpenEXR/ImfDeepTiledOutputPart.h",
        "src/lib/OpenEXR/ImfDoubleAttribute.h",
        "src/lib/OpenEXR/ImfDwaCompressor.h",
        "src/lib/OpenEXR/ImfEnvmap.h",
        "src/lib/OpenEXR/ImfEnvmapAttribute.h",
        "src/lib/OpenEXR/ImfExport.h",
        "src/lib/OpenEXR/ImfFastHuf.h",
        "src/lib/OpenEXR/ImfFloatAttribute.h",
        "src/lib/OpenEXR/ImfFloatVectorAttribute.h",
        "src/lib/OpenEXR/ImfForward.h",
        "src/lib/OpenEXR/ImfFrameBuffer.h",
        "src/lib/OpenEXR/ImfFramesPerSecond.h",
        "src/lib/OpenEXR/ImfGenericInputFile.h",
        "src/lib/OpenEXR/ImfGenericOutputFile.h",
        "src/lib/OpenEXR/ImfHeader.h",
        "src/lib/OpenEXR/ImfHuf.h",
        "src/lib/OpenEXR/ImfIDManifest.h",
        "src/lib/OpenEXR/ImfIDManifestAttribute.h",
        "src/lib/OpenEXR/ImfIO.h",
        "src/lib/OpenEXR/ImfInputFile.h",
        "src/lib/OpenEXR/ImfInputPart.h",
        "src/lib/OpenEXR/ImfInputPartData.h",
        "src/lib/OpenEXR/ImfInputStreamMutex.h",
        "src/lib/OpenEXR/ImfInt64.h",
        "src/lib/OpenEXR/ImfIntAttribute.h",
        "src/lib/OpenEXR/ImfKeyCode.h",
        "src/lib/OpenEXR/ImfKeyCodeAttribute.h",
        "src/lib/OpenEXR/ImfLineOrder.h",
        "src/lib/OpenEXR/ImfLineOrderAttribute.h",
        "src/lib/OpenEXR/ImfLut.h",
        "src/lib/OpenEXR/ImfMatrixAttribute.h",
        "src/lib/OpenEXR/ImfMisc.h",
        "src/lib/OpenEXR/ImfMultiPartInputFile.h",
        "src/lib/OpenEXR/ImfMultiPartOutputFile.h",
        "src/lib/OpenEXR/ImfMultiView.h",
        "src/lib/OpenEXR/ImfName.h",
        "src/lib/OpenEXR/ImfNamespace.h",
        "src/lib/OpenEXR/ImfOpaqueAttribute.h",
        "src/lib/OpenEXR/ImfOptimizedPixelReading.h",
        "src/lib/OpenEXR/ImfOutputFile.h",
        "src/lib/OpenEXR/ImfOutputPart.h",
        "src/lib/OpenEXR/ImfOutputPartData.h",
        "src/lib/OpenEXR/ImfOutputStreamMutex.h",
        "src/lib/OpenEXR/ImfPartHelper.h",
        "src/lib/OpenEXR/ImfPartType.h",
        "src/lib/OpenEXR/ImfPixelType.h",
        "src/lib/OpenEXR/ImfPizCompressor.h",
        "src/lib/OpenEXR/ImfPreviewImage.h",
        "src/lib/OpenEXR/ImfPreviewImageAttribute.h",
        "src/lib/OpenEXR/ImfPxr24Compressor.h",
        "src/lib/OpenEXR/ImfRational.h",
        "src/lib/OpenEXR/ImfRationalAttribute.h",
        "src/lib/OpenEXR/ImfRgba.h",
        "src/lib/OpenEXR/ImfRgbaFile.h",
        "src/lib/OpenEXR/ImfRgbaYca.h",
        "src/lib/OpenEXR/ImfRle.h",
        "src/lib/OpenEXR/ImfRleCompressor.h",
        "src/lib/OpenEXR/ImfScanLineInputFile.h",
        "src/lib/OpenEXR/ImfSimd.h",
        "src/lib/OpenEXR/ImfStandardAttributes.h",
        "src/lib/OpenEXR/ImfStdIO.h",
        "src/lib/OpenEXR/ImfStringAttribute.h",
        "src/lib/OpenEXR/ImfStringVectorAttribute.h",
        "src/lib/OpenEXR/ImfSystemSpecific.h",
        "src/lib/OpenEXR/ImfTestFile.h",
        "src/lib/OpenEXR/ImfThreading.h",
        "src/lib/OpenEXR/ImfTileDescription.h",
        "src/lib/OpenEXR/ImfTileDescriptionAttribute.h",
        "src/lib/OpenEXR/ImfTileOffsets.h",
        "src/lib/OpenEXR/ImfTiledInputFile.h",
        "src/lib/OpenEXR/ImfTiledInputPart.h",
        "src/lib/OpenEXR/ImfTiledMisc.h",
        "src/lib/OpenEXR/ImfTiledOutputFile.h",
        "src/lib/OpenEXR/ImfTiledOutputPart.h",
        "src/lib/OpenEXR/ImfTiledRgbaFile.h",
        "src/lib/OpenEXR/ImfTimeCode.h",
        "src/lib/OpenEXR/ImfTimeCodeAttribute.h",
        "src/lib/OpenEXR/ImfVecAttribute.h",
        "src/lib/OpenEXR/ImfVersion.h",
        "src/lib/OpenEXR/ImfWav.h",
        "src/lib/OpenEXR/ImfXdr.h",
        "src/lib/OpenEXR/ImfZip.h",
        "src/lib/OpenEXR/ImfZipCompressor.h",
        "src/lib/OpenEXR/OpenEXRConfig.h",
        "src/lib/OpenEXR/OpenEXRConfigInternal.h",
    ],
    features = select({
        ":windows": ["windows_export_all_symbols"],
        "//conditions:default": [],
    }),
    includes = [
        "src/lib",
        "src/lib/OpenEXR",
    ],
    linkopts =
        select({
            ":windows": [],
            "//conditions:default": [
                "-pthread",
            ],
        }),
    visibility = ["//visibility:public"],
    deps = [
        ":IlmThread",
        ":OpenEXRCore",
        "@imath",
    ],
)

cc_test(
    name = "IexTest",
    srcs = [
        "src/test/IexTest/main.cpp",
        "src/test/IexTest/testBaseExc.cpp",
        "src/test/IexTest/testBaseExc.h",
    ],
    includes = ["src/test/IexTest"],
    tags = ["manual"],  # This test is not build and executed in the CI
    deps = [
        ":Iex",
    ],
)

cc_binary(
    name = "exr2aces",
    srcs = ["src/bin/exr2aces/main.cpp"],
    deps = [
        ":OpenEXR",
    ],
)

cc_binary(
    name = "exrheader",
    srcs = ["src/bin/exrheader/main.cpp"],
    deps = [
        ":OpenEXR",
    ],
)

cc_binary(
    name = "exrenvmap",
    srcs = [
        "src/bin/exrenvmap/EnvmapImage.cpp",
        "src/bin/exrenvmap/blurImage.cpp",
        "src/bin/exrenvmap/main.cpp",
        "src/bin/exrenvmap/makeCubeMap.cpp",
        "src/bin/exrenvmap/makeLatLongMap.cpp",
        "src/bin/exrenvmap/readInputImage.cpp",
        "src/bin/exrenvmap/resizeImage.cpp",
    ] + glob(["src/bin/exrenvmap/*.h"]),
    includes = [
        "src/bin/exrenvmap",
    ],
    deps = [
        ":OpenEXR",
    ],
)

cc_binary(
    name = "exrstdattr",
    srcs = ["src/bin/exrstdattr/main.cpp"],
    deps = [
        ":OpenEXR",
    ],
)
